﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Diagnostics;
using System.Reflection;
using System.ComponentModel;
using Lilium.Configuration;

namespace Lilium.Web.Mvc.Configuration
{
	public class EmbeededResourceLibraryElement: ScriptResourceLibraryElement
	{
		#region public string ResourceAssembly

		private const string ResourceAssemblyPropertyName = "resourceAssembly";

		[ConfigurationPropertyAttribute(ResourceAssemblyPropertyName, IsRequired = true)]
		[TypeConverter(typeof(AssemblyNameConverter))]
		public Assembly ResourceAssembly { [DebuggerNonUserCodeAttribute] get { return (Assembly)base[ResourceAssemblyPropertyName]; } [DebuggerNonUserCodeAttribute] set { base[ResourceAssemblyPropertyName] = value; } }

		#endregion

		#region public string ResourceNamespace

		private const string ResourceNamespacePropertyName = "resourceNamespace";

		[ConfigurationPropertyAttribute(ResourceNamespacePropertyName, IsRequired = true)]
		public string ResourceNamespace { [DebuggerNonUserCodeAttribute] get { return (string)base[ResourceNamespacePropertyName]; } [DebuggerNonUserCodeAttribute] set { base[ResourceNamespacePropertyName] = value; } }

		#endregion

		public override ScriptResourceLibrary GetScriptResourceLibrary()
		{
			return new EmbeededScriptResourceLibrary(
				Name,
				ResourceAssembly,
				ResourceNamespace,
				ContentType,
				GetCachePolicy(),
				GetScriptResources());
		}
	}
}
